clear

set more off

use "data/dataLargeStakes.dta", replace


// Data management 
if 1 {

	rename switchBack multipleSwitchingRisk
	

	gen winKnown = win * known
	replace priorNum = priorNum / 100

	gen highInc = win > 50
	replace highInc = . if win == 0
	gen highInc_known = highInc * known
	
	gen win_known = win*known

	cap drop lose
	gen lose = abs(win - 100)
	replace lose = 100 if catastropheTreatment == 1
	
	gen betCE = bet * minCE
	replace betCE = . if win == 0
	
	
	gen firstHalf = order <= 16
	
	gen condition = .
	replace condition = 1  if known == 1 & catastropheTr == 1 & prior == "low"  & delayTr == 1
	replace condition = 2  if known == 1 & catastropheTr == 1 & prior == "mid"  & delayTr == 1
	replace condition = 3  if known == 1 & catastropheTr == 1 & prior == "high" & delayTr == 1
	replace condition = 4  if known == 1 & catastropheTr == 0 & prior == "low"  & delayTr == 1
	replace condition = 5  if known == 1 & catastropheTr == 0 & prior == "mid"  & delayTr == 1
	replace condition = 6  if known == 1 & catastropheTr == 0 & prior == "high" & delayTr == 1
	replace condition = 7  if known == 0 & catastropheTr == 1 & prior == "low"  & delayTr == 1
	replace condition = 8  if known == 0 & catastropheTr == 1 & prior == "mid"  & delayTr == 1
	replace condition = 9  if known == 0 & catastropheTr == 1 & prior == "high" & delayTr == 1
	replace condition = 10 if known == 0 & catastropheTr == 0 & prior == "low"  & delayTr == 1
	replace condition = 11 if known == 0 & catastropheTr == 0 & prior == "mid"  & delayTr == 1
	replace condition = 12 if known == 0 & catastropheTr == 0 & prior == "high" & delayTr == 1
	
	replace condition = 13   if known == 1 & catastropheTr == 1 & prior == "low"  & delayTr == 0
	replace condition = 14   if known == 1 & catastropheTr == 1 & prior == "mid"  & delayTr == 0
	replace condition = 15   if known == 1 & catastropheTr == 1 & prior == "high" & delayTr == 0
	replace condition = 16   if known == 1 & catastropheTr == 0 & prior == "low"  & delayTr == 0
	replace condition = 17   if known == 1 & catastropheTr == 0 & prior == "mid"  & delayTr == 0
	replace condition = 18   if known == 1 & catastropheTr == 0 & prior == "high" & delayTr == 0
	replace condition = 19   if known == 0 & catastropheTr == 1 & prior == "low"  & delayTr == 0
	replace condition = 20   if known == 0 & catastropheTr == 1 & prior == "mid"  & delayTr == 0
	replace condition = 21   if known == 0 & catastropheTr == 1 & prior == "high" & delayTr == 0
	replace condition = 22   if known == 0 & catastropheTr == 0 & prior == "low"  & delayTr == 0
	replace condition = 23   if known == 0 & catastropheTr == 0 & prior == "mid"  & delayTr == 0
	replace condition = 24   if known == 0 & catastropheTr == 0 & prior == "high" & delayTr == 0

	
	la de cond 	 1 "known, cat, delay, low " ///
				 2 "known, cat, delay, mid " ///
				 3 "known, cat, delay, high" ///
				 4 "known, noCat, delay, low " ///
				 5 "known, noCat, delay, mid " ///
				 6 "known, noCat, delay, high" ///
				 7 "unknown, cat, delay, low " ///
				 8 "unknown, cat, delay, mid " ///
				 9 "unknown, cat, delay, high" ///
				10 "unknown, noCat, delay, low " ///
				11 "unknown, noCat, delay, mid " ///
				12 "unknown, noCat, delay, high" ///
				13 "known, cat, noDelay, low " ///
				14 "known, cat, noDelay, mid " ///
				15 "known, cat, noDelay, high" ///
				16 "known, noCat, noDelay, low " ///
				17 "known, noCat, noDelay, mid " ///
				18 "known, noCat, noDelay, high" ///
				19 "unknown, cat, noDelay, low " ///
				20 "unknown, cat, noDelay, mid " ///
				21 "unknown, cat, noDelay, high" ///
				22 "unknown, noCat, noDelay, low " ///
				23 "unknown, noCat, noDelay, mid " ///
				24 "unknown, noCat, noDelay, high" 
	
	la val cond cond
	
	
	gen cond2 = condition
	replace cond2 = condition - 6 if condition >= 7 & condition <= 12
	replace cond2 = condition - 6 if condition >= 19 & condition <= 24
	
	

	gen adviceFollowed = bet == signal
	gen advicePositiveFollowed = (bet == 1) if (signal == 1)
	gen adviceNegativeFollowed = (bet == 0) if (signal == 0)
	
	// Define weights to account for stochastic signal realizations
	if 1 {
		
		// In each condition, should see 75% positive signals for those who select 
		// positively skewed information structure and 25% negative signals for 
		// those who select negatively skewed information structure. 
		
		cap gen weight = . 
		forvalues condition = 1 / 24 {
			foreach winAmt in 0 20 30 70 80  {
				local conditionInner = "condition == `condition' & win == `winAmt'"
				
				su priorNum if `conditionInner'
				local prior = r(mean)
				
				//(`prior'*1 + (1 - `prior')*0.5)
			
				su signal 							if `conditionInner' & infoStr == 1
				replace weight = (`prior'*1 + (1 - `prior')*0.5) 		/ r(mean)			if signal == 1 & `conditionInner' & infoStr == 1
				replace weight = (1- (`prior'*1 + (1 - `prior')*0.5)) 	/ (1 - r(mean)) 	if signal == 0 & `conditionInner' & infoStr == 1

				su signal 							if `conditionInner' & infoStr == 0
				replace weight = (`prior'*0.5 + (1 - `prior')*0) 		 / r(mean)			if signal == 1 & `conditionInner' & infoStr == 0
				replace weight = (1- (`prior'*0.5 + (1 - `prior')*0)) 	 / (1 - r(mean)) 	if signal == 0 & `conditionInner' & infoStr == 0
			}
		}
				
		reg signal [pw=weight] if infoStr == 1 & prior == "mid"
		reg signal [pw=weight] if infoStr == 0 & prior == "mid"
		reg signal if infoStr == 1
		
		reg winProb [pw = weight] if prior == "mid"		
		reg winProb  if prior == "mid"
		
		
		
	
		cap gen winAmt = win
		cap gen weightState = . 
		forvalues condition = 1 / 24 {
			foreach winAmt in 0 20 30 70 80 {
				local conditionInner = "condition == `condition' & winAmt == `winAmt'"
				
				su priorNum if `conditionInner'
				local prior = r(mean) / 100
				
			
				su state 							if `conditionInner'
				di `prior'
				di r(mean)
				di `winAmt'
				replace weightState = `prior' / r(mean)				if state == 1 & `conditionInner' 
				replace weightState = (1- `prior') 	/ (1 - r(mean)) if state == 0 & `conditionInner' 
			}
		}
		
		// drop data about that's about risk without corresponding info decision

		drop if bet == .

	
		// Define variables
		
		drop loss
		
		cap gen beliefDiff = belief - winProb
		cap gen loser = betCE < 0
		cap gen loss = min(betCE, 0)
		cap gen gain = max(betCE, 0)
		replace loss = . if betCE == .
		replace gain = . if betCE == .

			
	}
	


}


// Tables 
if 1 {
	
	// Table 2 and Supplementary Table B.2.A: UIH-normative
	if 1 {
		
		cap drop winMin
		gen winMin = win - 1
		replace winMin = . if win == 0
		
		set seed 1
		
		mysureg (gain winMin) /// 
				(loss winMin) ///
				if known == 1 & catastrophe == 0 ///
				, vce(cluster id)

		local mMin = 0
		noisily: nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
				- ([gain]win / ([gain]win - [loss]win))) ///
				(eq2:([gain]win / ([gain]win - [loss]win))) ///						
				, post
		

		mysureg (gain winMin) /// 
				(loss winMin) ///
				if known == 1 & catastrophe == 1 ///
				, vce(cluster id)			
		
		set seed 1
		
		
				
		mysureg (gain winMin) /// 
				(loss winMin) ///
				if known == 1 ///
				, vce(cluster id)

		local mMin = 0
		noisily: nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
				- ([gain]win / ([gain]win - [loss]win))) ///
				(eq2:([gain]win / ([gain]win - [loss]win))) ///						
				, post
				

				
				
		mysureg (gain winMin) /// 
				(loss winMin) ///
				if known == 0 ///
				, vce(cluster id)

		
		local mMin = 0
		nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
				- ([gain]win / ([gain]win - [loss]win))) ///
				(eq2:([gain]win / ([gain]win - [loss]win))) ///						
				, post		


		cap postclose welfareTable
		postfile welfareTable ///
				 aG str3 starsGainA double aL str3 starsLossA ///
				 bG str3 starsGain double bL str3 starsLoss ///
				 double alphaMin str4 starsAlpha ///
				 double alphaMax str4 starsAlphaMax ///
				 str4 cond double p ///
				 int obs subj ///
				 using "data/welfareTable.dta", replace
		
		foreach cond2 of numlist 14 17 {
			preserve 
				
				keep if known == 1
				keep if cond2 == `cond2'
				set seed 1
				
				mysureg (gain win) /// 
						(loss win) ///
					, vce(cluster id)
					
				local subj = e(N_clust)
				local obs = e(N)
			
				
				local mMin = 20
				local mMax = 80
				
				
				
				
				
				// Condition
				nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
						- ([gain]_cons + `mMax'*[gain]win) / (([gain]_cons + `mMax'*[gain]win) - ([loss]_cons +  `mMax'*[loss]win))) ///
						(eq2: (([gain]_cons + `mMax'*[gain]win) / (([gain]_cons + `mMax'*[gain]win) - ([loss]_cons +  `mMax'*[loss]win)))) ///	
						(eq3: ([gain]_cons + `mMin'*[gain]win)) ///
						(eq4: ([loss]_cons + `mMin'*[loss]win)) ///
						(eq5: (([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win)))) ///
						(eq6: ([gain]_cons + `mMax'*[gain]win)) ///
						(eq7: ([loss]_cons + `mMax'*[loss]win)) ///
					, post
				
				// New
				
				
				local bG = _b[eq6]
				local bL = _b[eq7]
				local seBg = _se[eq6] 
				local seBl = _se[eq7]
				
				test eq6 == 0
				local pGain = r(p)
				test eq7 == 0
				local pLoss = r(p)
				
				
				local starsGain = ""
				if (`pGain' <= 0.01) {
					local starsGain = "***"
				}
				if (`pGain' <= 0.05 & `pGain'>0.01) {
					local starsGain = "**"
				}
				if (`pGain' < 0.1 & `pGain'>0.05) {
					local starsGain = "*"
				}
				
				
				local starsLoss = ""
				if (`pLoss' <= 0.01) {
					local starsLoss = "***"
				}
				if (`pLoss' <= 0.05 & `pLoss'>0.01) {
					local starsLoss = "**"
				}
				if (`pLoss' < 0.1 & `pLoss'>0.05) {
					local starsLoss = "*"
				}
				
				// Previous
				
				local alphaMin = _b[eq2]
				local alphaSE = _se[eq2]
				local alphaMax = _b[eq5]
				local alphaMaxSE = _se[eq5]
				
				test eq2 == 0
				local pAlpha = r(p)
				
				local starsAlpha = ""
				if (`pAlpha' <= 0.01) {
					local starsAlpha = "***"
				}
				if (`pAlpha' <= 0.05 & `pAlpha'>0.01) {
					local starsAlpha = "**"
				}
				if (`pAlpha' < 0.1 & `pAlpha'>0.05) {
					local starsAlpha = "*"
				}

				local possibilityCond = "No"
				if (_b[eq1] >= 0) {
					local possibilityCond = "Yes"
				}
				
				
				test eq5 == 1
				local pAlphaMax = r(p)
				
				local starsAlphaMax = ""
				if (`pAlphaMax' <= 0.01) {
					local starsAlphaMax = "***"
				}
				if (`pAlphaMax' <= 0.05 & `pAlpha'>0.01) {
					local starsAlphaMax = "**"
				}
				if (`pAlphaMax' < 0.1 & `pAlpha'>0.05) {
					local starsAlphaMax = "*"
				}

				local possibilityCond = "No"
				if (_b[eq1] >= 0) {
					local possibilityCond = "Yes"
				}
				
				
				local aG = _b[eq3]
				local aGse = _se[eq3]
				local aL = _b[eq4]
				local aLse = _se[eq4]
				
				
				
				test _b[eq3] == 0
				local pGainA = r(p)
				test _b[eq4] == 0
				local pLossA = r(p)
				
				
				local starsGainA = ""
				if (`pGainA' <= 0.01) {
					local starsGainA = "***"
				}
				if (`pGainA' <= 0.05 & `pGainA'>0.01) {
					local starsGainA = "**"
				}
				if (`pGainA' < 0.1 & `pGainA'>0.05) {
					local starsGainA = "*"
				}
				
				
				local starsLossA = ""
				if (`pLossA' <= 0.01) {
					local starsLossA = "***"
				}
				if (`pLossA' <= 0.05 & `pLossA'>0.01) {
					local starsLossA = "**"
				}
				if (`pLossA' < 0.1 & `pLossA'>0.05) {
					local starsLossA = "*"
				}
				
				
				noisily: di "`possibilityCond'"
						
				test eq1
				local pTest = r(p)

				
			restore
			post welfareTable ///
				(`aG') ("`starsGainA'") (`aL') ("`starsLossA'")  ///
				(`bG') ("`starsGain'") (`bL') ("`starsLoss'") ///
				(`alphaMin') ("`starsAlpha'") (`alphaMax') ("`starsAlphaMax'") ///
				("`possibilityCond'") (`pTest') (`obs') (`subj')
							
			post welfareTable ///
				(`aGse') ("") (`aLse') ("") ///
				(`seBg') ("") (`seBl') ("") ///
				(`alphaSE') ("") (`alphaMaxSE') ("") ("") (.) (.) (.)
			
			
		}
		postclose welfareTable
		
		// Format the table: Table 2
		if 1 {
		preserve
			clear
			use "data/welfareTable.dta"
				
			keep alphaMin starsAlpha alphaMax starsAlphaMax cond p obs subj
				
			
			local format = "%9.3f"
			local aMin0   : display `format'   alphaMin[1]
			local aMin1   : display `format'   alphaMin[3]
			local aMinSe0 : display `format'   alphaMin[2]
			local aMinSe1 : display `format'   alphaMin[4]
			local starsAmin0 = starsAlpha[1]
			local starsAmin1 = starsAlpha[3]

			local aMax0   : display `format'   alphaMax[1]
			local aMax1   : display `format'   alphaMax[3]
			local aMaxSe0 : display `format'   alphaMax[2]
			local aMaxSe1 : display `format'   alphaMax[4]
			
			local starsAmax0 = starsAlphaMax[1]
			local starsAmax1 = starsAlphaMax[3]

			local p0 : display `format'    p[1]
			local p1 : display `format'    p[3]

			local uihNorm0 = cond[1]
			local uihNorm1 = cond[3]
			
			local obs0 = obs[1]
			local obs1 = obs[3]
			
			local subj0 = subj[1]
			local subj1 = subj[3]

			
			* Open the output file for writing
			cap file close myfile
			file open myfile using "../writeup/tables/Table2.tsv", write replace
			
				file write myfile "\quad min for \ $30 unacceptable, $\underline{\alpha}$ & `aMin0' `starsAmin0' & `aMin1' `starsAmin1' \\ " 
				file write myfile " & (`aMinSe0') & (`aMinSe1') \\" 
				file write myfile "\quad max for \ $3 acceptable, $\overline{\alpha}$ & `aMax0' `starsAmax0' & `aMax1' `starsAmax1'  \\ " 
				file write myfile "& (`aMaxSe0') & (`aMaxSe1') \\" 
				file write myfile "$ p $-value $\underline{\alpha} = \overline{\alpha}$ & `p0' & `p1' \\ "
				file write myfile "UIH-normative satisfied & No & No \\ "
				file write myfile "Observations & `obs0' & `obs1' \\"
				file write myfile "Subjects     & `subj0' & `subj1' \\"
			
			file close myfile

		restore
		}
		
		
		
		
		
		
		
		
		// Format the table: Supplementary Table B.2.A
		if 1 {
				preserve
					clear
					use "data/welfareTable.dta"
												   
					gen c1 = "("
					replace c1 = "" if mod(_n,2) == 1
				   
					gen c2 = ") & ("
					replace c2 = "  &  " if mod(_n,2) == 1
				   
					gen c3 = c2
					gen c4 = c2
					gen c5 = c2
					gen c6 = c2
				   
					gen c7 = ") & "
					replace c7 = "  &  " if mod(_n,2) == 1
				   
					gen c8 = " & "
				   
					gen c9 = " \\ "
				   
					order c1 aG starsGainA c2 ///
									 aL starsLossA c3 ///
									 alphaMax starsAlphaMax c6 ///
									 bG starsGain  c4 ///
									 bL starsLoss  c5 ///
									 alphaMin starsAlpha c7 ///
									 cond c8 p c9
				   
					gen line = (_n+1)/2
				   
					gen newline = .
					replace newline = line - 9       if line >= 10
					replace newline = line           if line >= 4 & line < 7
					replace newline = line           if line >= 7 & line < 10
					replace newline = line + 9       if line < 4

				   
					replace line = newline
					sort line
					drop line newline
				   
				   
					gen rowlabel = "&"
					replace rowlabel = "\quad Large & " if mod(_n, 6) == 1
					replace rowlabel = "\quad Limited & " if mod(_n, 6) == 3

				   
				   
					gen location = _n
					replace location = location - 4 if location >= 3
				   
					sort location
					drop location
					order rowlabel
				   
				   
					format aG aL alphaMax bG bL alphaMin  p %9.3f
					export delimited using "../writeup/tables/SupplementaryTableB2A.tsv", delimiter(tab)  datafmt novar replace
												   
			restore
            }
	}
		
	// Supplementary Table B.3.A and Supplementary Table B.4.A: UIH-normative alternative specifications
	if 1 {
		// Welfare table noise correction (Supplementary Table B.3.A)
		if 1 {
			
			cap drop gain  
			cap drop loss
			
			cap gen betCElasso = bet * minCElasso
			gen gain = max(betCElasso, 0)
			gen loss = min(betCElasso, 0)
			
			
			cap drop winMin
			gen winMin = win - 1
			replace winMin = . if win == 0
			
			set seed 1
			
			mysureg (gain winMin) /// 
					(loss winMin) ///
					if known == 1 & catastrophe == 0 ///
					, vce(cluster id)

			local mMin = 0
			noisily: nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
					- ([gain]win / ([gain]win - [loss]win))) ///
					(eq2:([gain]win / ([gain]win - [loss]win))) ///						
					, post
			

			mysureg (gain winMin) /// 
					(loss winMin) ///
					if known == 1 & catastrophe == 1 ///
					, vce(cluster id)			
			
			set seed 1
			
			
					
			mysureg (gain winMin) /// 
					(loss winMin) ///
					if known == 1 ///
					, vce(cluster id)

			local mMin = 0
			noisily: nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
					- ([gain]win / ([gain]win - [loss]win))) ///
					(eq2:([gain]win / ([gain]win - [loss]win))) ///						
					, post
					

					
					
			mysureg (gain winMin) /// 
					(loss winMin) ///
					if known == 0 ///
					, vce(cluster id)

			
			local mMin = 0
			nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
					- ([gain]win / ([gain]win - [loss]win))) ///
					(eq2:([gain]win / ([gain]win - [loss]win))) ///						
					, post		

		
			cap postclose welfareTable
			postfile welfareTable ///
					 aG str3 starsGainA double aL str3 starsLossA ///
					 bG str3 starsGain double bL str3 starsLoss ///
					 double alphaMin str4 starsAlpha ///
					 double alphaMax str4 starsAlphaMax ///
					 str4 cond double p ///
					 using "data/welfareTableLasso.dta", replace
			
			foreach cond2 of numlist 14 17 {
				preserve 
					
					keep if known == 1
					keep if cond2 == `cond2'
					set seed 1
					
					mysureg (gain win) /// 
							(loss win) ///
						, vce(cluster id)
				
					
					
					
					local mMin = 20
					local mMax = 80
					
					
					// Condition
					nlcom   (eq1:(([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win))) ///
							- ([gain]_cons + `mMax'*[gain]win) / (([gain]_cons + `mMax'*[gain]win) - ([loss]_cons +  `mMax'*[loss]win))) ///
							(eq2: (([gain]_cons + `mMax'*[gain]win) / (([gain]_cons + `mMax'*[gain]win) - ([loss]_cons +  `mMax'*[loss]win)))) ///	
							(eq3: ([gain]_cons + `mMin'*[gain]win)) ///
							(eq4: ([loss]_cons + `mMin'*[loss]win)) ///
							(eq5: (([gain]_cons + `mMin'*[gain]win) / (([gain]_cons + `mMin'*[gain]win) - ([loss]_cons +  `mMin'*[loss]win)))) ///
							(eq6: ([gain]_cons + `mMax'*[gain]win)) ///
							(eq7: ([loss]_cons + `mMax'*[loss]win)) ///
						, post
					
					// New
					
					
					local bG = _b[eq6]
					local bL = _b[eq7]
					local seBg = _se[eq6] 
					local seBl = _se[eq7]
					
					test eq6 == 0
					local pGain = r(p)
					test eq7 == 0
					local pLoss = r(p)
					
					
					local starsGain = ""
					if (`pGain' <= 0.01) {
						local starsGain = "***"
					}
					if (`pGain' <= 0.05 & `pGain'>0.01) {
						local starsGain = "**"
					}
					if (`pGain' < 0.1 & `pGain'>0.05) {
						local starsGain = "*"
					}
					
					
					local starsLoss = ""
					if (`pLoss' <= 0.01) {
						local starsLoss = "***"
					}
					if (`pLoss' <= 0.05 & `pLoss'>0.01) {
						local starsLoss = "**"
					}
					if (`pLoss' < 0.1 & `pLoss'>0.05) {
						local starsLoss = "*"
					}
					
					// Previous
					
					local alphaMin = _b[eq2]
					local alphaSE = _se[eq2]
					local alphaMax = _b[eq5]
					local alphaMaxSE = _se[eq5]
					
					test eq2 == 0
					local pAlpha = r(p)
					
					local starsAlpha = ""
					if (`pAlpha' <= 0.01) {
						local starsAlpha = "***"
					}
					if (`pAlpha' <= 0.05 & `pAlpha'>0.01) {
						local starsAlpha = "**"
					}
					if (`pAlpha' < 0.1 & `pAlpha'>0.05) {
						local starsAlpha = "*"
					}

					local possibilityCond = "No"
					if (_b[eq1] >= 0) {
						local possibilityCond = "Yes"
					}
					
					
					test eq5 == 1
					local pAlphaMax = r(p)
					
					local starsAlphaMax = ""
					if (`pAlphaMax' <= 0.01) {
						local starsAlphaMax = "***"
					}
					if (`pAlphaMax' <= 0.05 & `pAlpha'>0.01) {
						local starsAlphaMax = "**"
					}
					if (`pAlphaMax' < 0.1 & `pAlpha'>0.05) {
						local starsAlphaMax = "*"
					}

					local possibilityCond = "No"
					if (_b[eq1] >= 0) {
						local possibilityCond = "Yes"
					}
					
					
					local aG = _b[eq3]
					local aGse = _se[eq3]
					local aL = _b[eq4]
					local aLse = _se[eq4]
					
					
					
					test _b[eq3] == 0
					local pGainA = r(p)
					test _b[eq4] == 0
					local pLossA = r(p)
					
					
					local starsGainA = ""
					if (`pGainA' <= 0.01) {
						local starsGainA = "***"
					}
					if (`pGainA' <= 0.05 & `pGainA'>0.01) {
						local starsGainA = "**"
					}
					if (`pGainA' < 0.1 & `pGainA'>0.05) {
						local starsGainA = "*"
					}
					
					
					local starsLossA = ""
					if (`pLossA' <= 0.01) {
						local starsLossA = "***"
					}
					if (`pLossA' <= 0.05 & `pLossA'>0.01) {
						local starsLossA = "**"
					}
					if (`pLossA' < 0.1 & `pLossA'>0.05) {
						local starsLossA = "*"
					}
					
					
					noisily: di "`possibilityCond'"
							
					test eq1
					local pTest = r(p)

					
				restore
				post welfareTable ///
					(`aG') ("`starsGainA'") (`aL') ("`starsLossA'")  ///
					(`bG') ("`starsGain'") (`bL') ("`starsLoss'") ///
					(`alphaMin') ("`starsAlpha'") (`alphaMax') ("`starsAlphaMax'") ///
					("`possibilityCond'") (`pTest')
								
				post welfareTable ///
					(`aGse') ("") (`aLse') ("") ///
					(`seBg') ("") (`seBl') ("") ///
					(`alphaSE') ("") (`alphaMaxSE') ("") ("") (.)
				
				
			}
			postclose welfareTable
			
			// Format the table: Supplementary Table B.3.A
			preserve
				clear
				use "data/welfareTableLasso.dta"
								
				gen c1 = "("
				replace c1 = "" if mod(_n,2) == 1
				
				gen c2 = ") & ("
				replace c2 = "  &  " if mod(_n,2) == 1
				
				gen c3 = c2
				gen c4 = c2
				gen c5 = c2
				gen c6 = c2
				
				gen c7 = ") & "
				replace c7 = "  &  " if mod(_n,2) == 1
				
				gen c8 = " & " 
				
				gen c9 = " \\ "
				
				order c1 aG starsGainA c2 /// 
						 aL starsLossA c3 ///
						 alphaMax starsAlphaMax c6 ///
						 bG starsGain  c4 /// 
						 bL starsLoss  c5 /// 
						 alphaMin starsAlpha c7 ///
						 cond c8 p c9
				
				gen line = (_n+1)/2
				
				gen newline = .
				replace newline = line - 9 	if line >= 10
				replace newline = line   	if line >= 4 & line < 7
				replace newline = line   	if line >= 7 & line < 10
				replace newline = line + 9 	if line < 4

				
				replace line = newline 
				sort line 
				drop line newline
				
				
				gen rowlabel = "&"
				replace rowlabel = "\quad Large & " if mod(_n, 6) == 1
				replace rowlabel = "\quad Limited & " if mod(_n, 6) == 3

				
				
				gen location = _n
				replace location = location - 4 if location >= 3
				
				sort location
				drop location
				order rowlabel
				
				
				format aG aL alphaMax bG bL alphaMin  p %9.3f
				export delimited using "../writeup/tables/SupplementaryTableB3A", delimiter(tab)  datafmt novar replace
								
			restore
			
		}

		// Welfare table ex post benchmark (Supplementary Table B.4.A)
		if 1 {
			
			
			
			cap drop gainPat
			cap drop lossPat
			gen gainPat = bet*win*state
			gen lossPat = bet*(win - 100)*(1-state)
			replace lossPat = bet*(- 100)*(1-state) if catastropheTreatment == 1
			
			
			cap drop winMin
			gen winMin = win - 1
			replace winMin = . if win == 0
			
			set seed 1
			
			mysureg (gainPat winMin) /// 
					(lossPat winMin) ///
					if known == 1 & catastrophe == 0 ///
					, vce(cluster id)

			local mMin = 0
			noisily: nlcom   (eq1:(([gainPat]_cons + `mMin'*[gainPat]win) / (([gainPat]_cons + `mMin'*[gainPat]win) - ([lossPat]_cons +  `mMin'*[lossPat]win))) ///
					- ([gainPat]win / ([gainPat]win - [lossPat]win))) ///
					(eq2:([gainPat]win / ([gainPat]win - [lossPat]win))) ///						
					, post
			

			mysureg (gainPat winMin) /// 
					(lossPat winMin) ///
					if known == 1 & catastrophe == 1 ///
					, vce(cluster id)			
			
			set seed 1
			
			
					
			mysureg (gainPat winMin) /// 
					(lossPat winMin) ///
					if known == 1 ///
					, vce(cluster id)

			local mMin = 0
			noisily: nlcom   (eq1:(([gainPat]_cons + `mMin'*[gainPat]win) / (([gainPat]_cons + `mMin'*[gainPat]win) - ([lossPat]_cons +  `mMin'*[lossPat]win))) ///
					- ([gainPat]win / ([gainPat]win - [lossPat]win))) ///
					(eq2:([gainPat]win / ([gainPat]win - [lossPat]win))) ///						
					, post
					

					
					
			mysureg (gainPat winMin) /// 
					(lossPat winMin) ///
					if known == 0 ///
					, vce(cluster id)

			
			local mMin = 0
			nlcom   (eq1:(([gainPat]_cons + `mMin'*[gainPat]win) / (([gainPat]_cons + `mMin'*[gainPat]win) - ([lossPat]_cons +  `mMin'*[lossPat]win))) ///
					- ([gainPat]win / ([gainPat]win - [lossPat]win))) ///
					(eq2:([gainPat]win / ([gainPat]win - [lossPat]win))) ///						
					, post		


			cap postclose welfareTable
			postfile welfareTable ///
					 aG str3 starsgainPatA double aL str3 starslossPatA ///
					 bG str3 starsgainPat double bL str3 starslossPat ///
					 double alphaMin str4 starsAlpha ///
					 double alphaMax str4 starsAlphaMax ///
					 str4 cond double p ///
					 using "data/welfareTable.dta", replace
			
			foreach cond2 of numlist 14 17 {
				preserve 
					
					keep if known == 1
					keep if cond2 == `cond2'
					set seed 1
					
					mysureg (gainPat win) /// 
							(lossPat win) ///
						, vce(cluster id)
				
					
					
					
					local mMin = 20
					local mMax = 80
					
					
					// Condition
					nlcom   (eq1:(([gainPat]_cons + `mMin'*[gainPat]win) / (([gainPat]_cons + `mMin'*[gainPat]win) - ([lossPat]_cons +  `mMin'*[lossPat]win))) ///
							- ([gainPat]_cons + `mMax'*[gainPat]win) / (([gainPat]_cons + `mMax'*[gainPat]win) - ([lossPat]_cons +  `mMax'*[lossPat]win))) ///
							(eq2: (([gainPat]_cons + `mMax'*[gainPat]win) / (([gainPat]_cons + `mMax'*[gainPat]win) - ([lossPat]_cons +  `mMax'*[lossPat]win)))) ///	
							(eq3: ([gainPat]_cons + `mMin'*[gainPat]win)) ///
							(eq4: ([lossPat]_cons + `mMin'*[lossPat]win)) ///
							(eq5: (([gainPat]_cons + `mMin'*[gainPat]win) / (([gainPat]_cons + `mMin'*[gainPat]win) - ([lossPat]_cons +  `mMin'*[lossPat]win)))) ///
							(eq6: ([gainPat]_cons + `mMax'*[gainPat]win)) ///
							(eq7: ([lossPat]_cons + `mMax'*[lossPat]win)) ///
						, post
					
					// New
					
					
					local bG = _b[eq6]
					local bL = _b[eq7]
					local seBg = _se[eq6] 
					local seBl = _se[eq7]
					
					test eq6 == 0
					local pgainPat = r(p)
					test eq7 == 0
					local plossPat = r(p)
					
					
					local starsgainPat = ""
					if (`pgainPat' <= 0.01) {
						local starsgainPat = "***"
					}
					if (`pgainPat' <= 0.05 & `pgainPat'>0.01) {
						local starsgainPat = "**"
					}
					if (`pgainPat' < 0.1 & `pgainPat'>0.05) {
						local starsgainPat = "*"
					}
					
					
					local starslossPat = ""
					if (`plossPat' <= 0.01) {
						local starslossPat = "***"
					}
					if (`plossPat' <= 0.05 & `plossPat'>0.01) {
						local starslossPat = "**"
					}
					if (`plossPat' < 0.1 & `plossPat'>0.05) {
						local starslossPat = "*"
					}
					
					// Previous
					
					local alphaMin = _b[eq2]
					local alphaSE = _se[eq2]
					local alphaMax = _b[eq5]
					local alphaMaxSE = _se[eq5]
					
					test eq2 == 0
					local pAlpha = r(p)
					
					local starsAlpha = ""
					if (`pAlpha' <= 0.01) {
						local starsAlpha = "***"
					}
					if (`pAlpha' <= 0.05 & `pAlpha'>0.01) {
						local starsAlpha = "**"
					}
					if (`pAlpha' < 0.1 & `pAlpha'>0.05) {
						local starsAlpha = "*"
					}

					local possibilityCond = "No"
					if (_b[eq1] >= 0) {
						local possibilityCond = "Yes"
					}
					
					
					test eq5 == 1
					local pAlphaMax = r(p)
					
					local starsAlphaMax = ""
					if (`pAlphaMax' <= 0.01) {
						local starsAlphaMax = "***"
					}
					if (`pAlphaMax' <= 0.05 & `pAlpha'>0.01) {
						local starsAlphaMax = "**"
					}
					if (`pAlphaMax' < 0.1 & `pAlpha'>0.05) {
						local starsAlphaMax = "*"
					}

					local possibilityCond = "No"
					if (_b[eq1] >= 0) {
						local possibilityCond = "Yes"
					}
					
					
					local aG = _b[eq3]
					local aGse = _se[eq3]
					local aL = _b[eq4]
					local aLse = _se[eq4]
					
					
					
					test _b[eq3] == 0
					local pgainPatA = r(p)
					test _b[eq4] == 0
					local plossPatA = r(p)
					
					
					local starsgainPatA = ""
					if (`pgainPatA' <= 0.01) {
						local starsgainPatA = "***"
					}
					if (`pgainPatA' <= 0.05 & `pgainPatA'>0.01) {
						local starsgainPatA = "**"
					}
					if (`pgainPatA' < 0.1 & `pgainPatA'>0.05) {
						local starsgainPatA = "*"
					}
					
					
					local starslossPatA = ""
					if (`plossPatA' <= 0.01) {
						local starslossPatA = "***"
					}
					if (`plossPatA' <= 0.05 & `plossPatA'>0.01) {
						local starslossPatA = "**"
					}
					if (`plossPatA' < 0.1 & `plossPatA'>0.05) {
						local starslossPatA = "*"
					}
					
					
					noisily: di "`possibilityCond'"
							
					test eq1
					local pTest = r(p)

					
				restore
				post welfareTable ///
					(`aG') ("`starsgainPatA'") (`aL') ("`starslossPatA'")  ///
					(`bG') ("`starsgainPat'") (`bL') ("`starslossPat'") ///
					(`alphaMin') ("`starsAlpha'") (`alphaMax') ("`starsAlphaMax'") ///
					("`possibilityCond'") (`pTest')
								
				post welfareTable ///
					(`aGse') ("") (`aLse') ("") ///
					(`seBg') ("") (`seBl') ("") ///
					(`alphaSE') ("") (`alphaMaxSE') ("") ("") (.)
				
				
			}
			postclose welfareTable
			
			// Format the table: Supplementary Table B.4.A
			preserve
				clear
				use "data/welfareTable.dta"
								
				gen c1 = "("
				replace c1 = "" if mod(_n,2) == 1
				
				gen c2 = ") & ("
				replace c2 = "  &  " if mod(_n,2) == 1
				
				gen c3 = c2
				gen c4 = c2
				gen c5 = c2
				gen c6 = c2
				
				gen c7 = ") & "
				replace c7 = "  &  " if mod(_n,2) == 1
				
				gen c8 = " & " 
				
				gen c9 = " \\ "
				
				order c1 aG starsgainPatA c2 /// 
						 aL starslossPatA c3 ///
						 alphaMax starsAlphaMax c6 ///
						 bG starsgainPat  c4 /// 
						 bL starslossPat  c5 /// 
						 alphaMin starsAlpha c7 ///
						 cond c8 p c9
				
				gen line = (_n+1)/2
				
				gen newline = .
				replace newline = line - 9 	if line >= 10
				replace newline = line   	if line >= 4 & line < 7
				replace newline = line   	if line >= 7 & line < 10
				replace newline = line + 9 	if line < 4

				
				replace line = newline 
				sort line 
				drop line newline
				
				
				gen rowlabel = "&"
				replace rowlabel = "\quad Large & " if mod(_n, 6) == 1
				replace rowlabel = "\quad Limited & " if mod(_n, 6) == 3

				
				
				gen location = _n
				replace location = location - 4 if location >= 3
				
				sort location
				drop location
				order rowlabel
				
				
				format aG aL alphaMax bG bL alphaMin  p %9.3f
				export delimited using "../writeup/tables/SupplementaryTableB4A.tsv", delimiter(tab)  datafmt novar replace
								
			restore
			
		}
	}		


}


// Figures 
if 1 {
	
	// Figure 4.A and Supplementary Figure B.1.A: Info choice pooled
	if 1 {
	preserve 

		keep if win > 0
		cap gen win2k 	= win <= 30 & known == 1
		cap gen win10k 	= win >= 70 & known == 1

		cap gen win2u 	= win <= 30 & known == 0
		cap gen win10u 	= win >= 70 & known == 0

		reg infoStr win*k win*u, nocons cl(id)
		local s2k = _se[win2k]
		local s10k = _se[win10k]
		local s2u = _se[win2u]
		local s10u = _se[win10u]
		
		replace win = 30 if win <= 30
		replace win = 70 if win >= 70
		
		local aspect = 0.75
		collapse infoStr highInc, by(win known)
		
		gen se = .
		replace se = `s2k'  if win <= 30 & known == 1
		replace se = `s10k' if win >= 70 & known == 1
		
		replace se = `s2u'  if win <= 30 & known == 0
		replace se = `s10u' if win >= 70 & known == 0
		
		gen upper = infoStr + 1.96*se
		gen lower = infoStr - 1.96*se
		
		replace win = win + 0.5 if known == 1
		replace win = win - 0.5 if known == 0
		
		// Customize graph scheme - main text
		grstyle init
		grstyle set graphsize 64mm 88mm
		grstyle set margin "7.5mm 7.5mm 2.5mm 2.5mm": graph
		grstyle set size 7pt: heading subheading body small_body text_option axis_title tick_label minortick_label key_label
		
		
		tw 	(line infoStr win 		if known == 1, lcolor(navy) 	lpattern(solid) 	lwidth(0.75)) ///
			(line infoStr win 		if known == 0, lcolor(maroon) 	lpattern(longdash)	lwidth(0.75)) ///
			(rcap upper lower win 	if known == 1, lcolor(navy)) ///
			(rcap upper lower win 	if known == 0, lcolor(maroon)) ///
			, name(gr1, replace) ///
			ylabel(0(0.2)0.6, angle(90)) /// 
			ytitle("Frequency bold advisor chosen") ///
			xtitle("Incentive amount") legend(order(1 "Incentive First" 2 "Advisor Choice First")  ring(0) col(1) pos(5) region(lc(black))) ///
			bgcolor(white) graphregion(color(white)) ///
			xlabel(30 "{&le} {c 0128}30" 70 "{&ge} {c 0128}70") ///
			xscale(range(20 80)) ///
			aspect(0.8)
		graph export "../writeup/graphs/Figure4A.pdf", replace
		export excel "../writeup/sourceDataFigures/sourceData_Figure4.xlsx", firstrow(variables) sheet("Figure4A", replace)
		
		// Clear customized graph scheme
		grstyle clear
		
		// Customize graph scheme - supplementary information
		grstyle init
		grstyle set graphsize 64mm 88mm
		grstyle set margin "5mm 5mm 2.5mm 2.5mm": graph
		grstyle set size 7pt: heading subheading body small_body text_option axis_title tick_label minortick_label key_label
		
		
		tw 	(line infoStr win 		if known == 1, lcolor(navy) 	lpattern(solid) 	lwidth(0.75)) ///
			(line infoStr win 		if known == 0, lcolor(maroon) 	lpattern(longdash)	lwidth(0.75)) ///
			(rcap upper lower win 	if known == 1, lcolor(navy)) ///
			(rcap upper lower win 	if known == 0, lcolor(maroon)) ///
			, name(gr1, replace) ///
			ylabel(0(0.2)0.6, angle(90)) /// 
			ytitle("Frequency bold advisor chosen") ///
			xtitle("Incentive amount") legend(order(1 "Incentive First" 2 "Advisor Choice First")  ring(0) col(1) pos(5) region(lc(black))) ///
			bgcolor(white) graphregion(color(white)) ///
			xlabel(30 "{&le} {c 0128}30" 70 "{&ge} {c 0128}70") ///
			xscale(range(20 80)) ///
			scale(1.3)
		graph export "../writeup/graphs/SupplementaryFigureB1A.pdf", replace
		export excel "../writeup/sourceDataFigures/sourceData_SupplementaryFigureB1.xlsx", firstrow(variables) sheet("FigureB1A", replace)
		
		// Clear customized graph scheme
		grstyle clear
		
		
	restore
	}

	// Figure 4.B and Supplementary Figure B.1.E: CDF welfare
	if 1 {
		preserve

			cap cumul betCE if known == 1 & highInc == 1 [aw = weight], gen(diffHighTr)
			cap cumul betCE if known == 1 & highInc == 0 [aw = weight], gen(diffLowTr)
			
			sort diffHighTr diffLowTr 
			
			
			// Customize graph scheme - main text
			grstyle init
			grstyle set graphsize 64mm 88mm
			grstyle set margin "7.5mm 7.5mm 2.5mm 2.5mm": graph
			grstyle set size 7pt: heading subheading body small_body text_option axis_title tick_label minortick_label key_label
						
			tw	(line diffHighTr betCE, lwidth(0.5) lcolor(navy) 	lpattern(solid)) ///
				(line diffLowTr  betCE, lwidth(0.5) lcolor(maroon) 	lpattern(shortdash)) ///
				, ///
				xtitle("Ex-ante surplus in {c 0128}") ///
				ytitle("Cumulative frequency") ///
				ylabel(, angle(90)) ///
				legend(order(1 "Incentive {&ge} {c 0128} 70" 2 "Incentive {&le} {c 0128} 30") ring(0) col(1) pos(10) region(lc(black))) ///		
				xline(0, lcolor(black) lpattern(solid) lwidth(0.25)) ///
				bgcolor(white) graphregion(color(white))
			graph export "../writeup/graphs/Figure4B.pdf", replace
			keep diffHighTr diffLowTr betCE
			export excel "../writeup/sourceDataFigures/sourceData_Figure4.xlsx", firstrow(variables) sheet("Figure4B", modify)
			
			// Clear customized graph scheme
			grstyle clear
			
			// Customize graph scheme - supplementary information
			grstyle init
			grstyle set graphsize 64mm 88mm
			grstyle set margin "5mm 5mm 2.5mm 2.5mm": graph
						
			tw	(line diffHighTr betCE, lwidth(0.5) lcolor(navy) 	lpattern(solid)) ///
				(line diffLowTr  betCE, lwidth(0.5) lcolor(maroon) 	lpattern(shortdash)) ///
				, ///
				xtitle("Ex-ante surplus in {c 0128}") ///
				ytitle("Cumulative frequency") ///
				ylabel(, angle(90)) ///
				legend(order(1 "Incentive {&ge} {c 0128} 70" 2 "Incentive {&le} {c 0128} 30") ring(0) col(1) pos(10) region(lc(black))) ///		
				xline(0, lcolor(black) lpattern(solid) lwidth(0.25)) ///
				bgcolor(white) graphregion(color(white)) ///
				scale(1.3)
			graph export "../writeup/graphs/SupplementaryFigureB1E.pdf", replace
			export excel "../writeup/sourceDataFigures/sourceData_SupplementaryFigureB1.xlsx", firstrow(variables) sheet("FigureB1E", modify)
			
			// Clear customized graph scheme
			grstyle clear
			
		restore
	}

	// Supplementary Figure B.1.C: Effect on posteriors
	if 1 {

		reg belief highInc if known == 1, cl(id)
		
		// This used in text: 
		reg belief highInc catastropheTr if known == 1, cl(id)

		reg belief highInc known win_known, cl(id)
		reg belief highInc known win_known catastropheTr, cl(id)

		
		preserve
			keep if known == 1
			
			cumul belief if highInc == 0, gen(cumBel0)
			cumul belief if highInc == 1, gen(cumBel1)
			sort  cumBel0 cumBel1 belief
			
			// Customize graph scheme
			grstyle init
			grstyle set graphsize 88mm 88mm
			grstyle set margin "2.5mm 2.5mm 2.5mm 2.5mm": graph

			tw	(line cumBel0 belief if highInc == 0, lcolor(navy)) ///
				(line cumBel1 belief if highInc == 1, lcolor(maroon) lpattern(shortdash)) ///
				, ///
				xlabel(0 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 1) ///
				ylab(0(0.2)1, nogrid angle(90)) ///
				ytitle("Cumulative frequency") ///
				xtitle("Subjective belief P(s=G) ") ///
				ysize(2) xsize(2) ///
				plotregion(margin(zero)) ///
				legend(order(1 "Incentive {&le} {c 0128}30" 2 "Incentive {&ge} {c 0128}70") col(1) ring(0) pos(11) region(lc(black))) ///
				aspect(1) bgcolor(white) graphregion(color(white)) ///
				scale(1.2)
			graph export "../writeup/graphs/SupplementaryFigureB1C.pdf", replace
			keep cumBel0 cumBel1 belief highInc
			export excel "../writeup/sourceDataFigures/sourceData_SupplementaryFigureB1.xlsx", firstrow(variables) sheet("FigureB1C", modify)
			
			// Clear customized graph scheme
			grstyle clear
			
		restore

	}

	
}	

	
// Statistics mentioned in flow text
if 1 {
	
	// Information choice summary statistics
	if 1 {
		su infoStr if win <= 30 & win ~= 0 & known == 1
		su infoStr if win <= 30 & known == 1
		su infoStr if win >= 70 & known == 1
		
		reg infoStr highInc if known == 1, cl(id)
		reg infoStr highInc highInc_known, cl(id)
		test highInc_known
		
		su infoStr if win == 20 & known == 1
		su infoStr if win == 80 & known == 1
		su infoStr if known == 0
		reg infoStr win if known == 1, cl(id)
		reg infoStr win known win_known, cl(id)
		
		}

	// Beliefs
	if 1 {
		su belief
		su belief if highInc == 0 & known == 1
		su belief if highInc == 1 & known == 1
		
		gen beliefMinus50 = belief - 0.5
		reg beliefMinus50 if known == 1 & highInc == 0, cl(id)
		reg beliefMinus50 if known == 1 & highInc == 1, cl(id)
		
		reg belief highInc if known == 1, cl(id)
		test _cons = 0.5
		lincom _b[_cons] + _b[highInc]
		reg belief if known == 1 & highInc == 0
		test _cons = 0.5
		reg belief if known == 1 & highInc == 1
		test _cons = 0.5
		
		
	// Multiple switching summary statistics
	if 1 {
			su multipleS

			gen numRoundsMultiSw = 26 * fracMultiSw
		   
			su numRoundsMultiSw, d
		   
			su everMultiSw, d
						   
	}
   
	tab male if tag == 1
   
	replace age = age + 17
	su age if tag == 1
   
	// Supply summary statistics
	if 1 {
   
			su bet if win == 80 & known == 0
			local supplyUnknown = r(mean)
			su bet if win == 80 & known == 1
			local supplyKnown = r(mean)
			local diff = `supplyKnown' - `supplyUnknown'
			di `diff'
		   
			reg bet known win win_known, cl(id)
			reg bet win if known == 1, cl(id)
			noisily: di _b[win]*100*16.67
			reg bet win if known == 0, cl(id)
			noisily: di _b[win]*100*16.67

	}
   
	// Welfare
	if 1 {
		   
			su gain if known == 1 & win == 20
			local b = r(mean)
			su loss if known == 1 & win == 20
			local a = abs(r(mean))
			di `b'/(`a'+`b')

			su gain if known == 1 & win == 80
			local b = r(mean)
			su loss if known == 1 & win == 80
			local a = abs(r(mean))
			di `b'/(`a'+`b')
		          
               
                }
		
		}
	
	
	}
	
	